import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from '@/router/routes'
Vue.use(VueRouter)
//解决多次执行会抛出NavigationDuplicated的警告错误
//首先保存原来的方法
const originPush = VueRouter.prototype.push;
//再写新方法
VueRouter.prototype.push = function(location,resolved,rejected) {//考虑要用this所以不可以用箭头函数
    if(resolved === undefined && rejected === undefined){
        return originPush.call(this,location).catch(()=>{})//VueRouter的prototype里的方法是给他的实例router用的，所以this指向router
    }else{
        return originPush.call(this,location,resolved,rejected)
    }
}
export default new VueRouter({
    routes,//注册路由
})